<{include file="Common/head"}>
<{include file="Common/menu"}>

<link href="_index_/yy/index.css" rel="stylesheet">
<link href="_index_/yy/laydate.css" rel="stylesheet">
<script src="_index_/yy/laydate.js"></script>
<script type="text/javascript" src="_index_/laydate/laydate.js"></script>

<style type="text/css">
*{font-size: 15px!important;}

    .layui-input{
        width: 100px;
    }
</style>

<section class="Hui-article-box">

    <form class="appointment">
        <ul>


            <li>
                <h2>账号：</h2>
                <input type="text" autocomplete="off" name="user" class="layui-input user"  placeholder="输入账号">
            </li>
            <li>
                <h2>密码：</h2>
                <input type="text" autocomplete="off" name="password" class="layui-input password"  placeholder="输入密码">
            </li>

            <li></li>
        </ul>

    </form>
    <div><input class="btn btn-success radius submit" type="button" value="添加" style="margin-left: 40px;"></div>

    <br/>
    <br/>

    <div id="my_table">
        <table class="table table-border table-bordered table-striped table-hover table-bg tablesorter" id="mytable">
            <thead>
            <tr class="text-c">
                <th>账号</th>
                <th>操作</th>

            </tr>
            </thead>
            <tbody class="tbody">


            <{volist name="data" id="vo"}>

            <tr>
                <td><{$vo.uname}></td>
                <td>

                    <input class="btn radius btn-warning" ids="<{$vo.id}>" uname="<{$vo.uname}>" type="button" value="修改">
                    <input class="btn btn-danger radius delete" ids="<{$vo.id}>" type="button" value="删除">
                </td>
            </tr>
            <{/volist}>

            </tbody>
        </table>
    </div>
</section>
<script>
    //修改
    $(".btn-warning").on("click",function(){
        id = $(this).attr("ids");
        uname=$(this).attr("uname");
        location.href="/index/Set/updatepass?id="+id+"&uname="+uname;

    })
    //删除
    $(".delete").on("click",function(){
        id = $(this).attr("ids");
        var postdata = {"id":id};

        $.post("/index/Set/deleteuser",postdata,function(e){
            if(e==1){
                Huimodalalert('删除成功',2000)
            }else{

            }
        });
    })

    $(".submit").on("click",function(){
        user     = $(".user").val();        //账号
        password     = $(".password").val();        //密码

        if(user==''||password==''){
            alert("账号和密码不能为空");
            return false;
        }

        var postdata = {
            "user":user,
            "password":password
        };
        //console.log(postdata);


        $.post("/index/Set/adduser",postdata,function(e){
            console.log(e);
            if(e==1){
                $.Huimodalalert('添加成功',2000);
                window.close();
                setInterval(function(){
                    location.reload();
                },2000)
            }else{

            }
        });
    })

    function Huimodalalert(text,second){
        $.Huimodalalert(text,second);
        window.close();
        setInterval(function(){
            location.reload();
        },second)
    }
</script>
<{include file="Common/footer"}>